package com.zzedu.enmuns;

import java.util.Arrays;

public enum SchoolStateEnums {
    NORMAL(0, "正常"),
    PAUSE(1, "暂停"),
    DISABLE(2, "停用"),
    ;
    final int code;

    final String desc;

    SchoolStateEnums(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static SchoolStateEnums getCode(Integer code) {
        if (code == null) {
            return null;
        }
        return Arrays.stream(SchoolStateEnums.values()).filter(e -> e.getCode() == code).findFirst().orElse(null);
    }

    @Override
    public String toString() {
        return String.valueOf(code); // 或者 name(), 或者 desc
    }
}
